package com.io.convert;

import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;

/**
 * Administrator
 *
 * @author jiangbang
 * @date 2016/6/3
 */
public class FIleUtil {

    /**
     * 工具类关闭流
     * 可变参数：... 只能形参最后一个位置，处理方式与数组一致
     */
    public static void close(Closeable ... io){
        for(Closeable temp:io){
            try {
                if(null!=temp){
                    temp.close();
                }
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }

    public static <T extends  Closeable> void closeAll(T ... io){
        for(T temp:io){
            try {
                if(null!=temp){
                    temp.close();
                }
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }


    public static void main(String[] args) {
        InputStream is = null;
        OutputStream os = null;
        FIleUtil.close(is,os);
    }


}
